package com.oo.packaging_2.hero;

/**
 * Hero--${description}
 *
 * @author: Jovi
 * @createTime: 2017-04-19 13:46
 **/
public class Hero {

    private String name;

    private int blood;

    private int attackPower;

    private int defendPower;

    private Skill mySkill;

    public Hero(String name, int blood, int attackPower, int defendPower, Skill mySkill) {
        this.name = name;
        this.blood = blood;
        this.attackPower = attackPower;
        this.defendPower = defendPower;
        this.mySkill = mySkill;
    }

    public Hero() {
    }

    public String attack() {
        return "英雄"+this.name+"\n展开攻击\n当前生命值是："+
                this.blood+"\n攻击力是："+(this.attackPower+this.mySkill.getAttackPower());
    }

    public void recovery(int attackPower) {
        int def = this.defendPower+this.mySkill.getDefendPower();
        if (def >= attackPower) {
            System.out.println("防御成功！\n英雄" + this.name + "以" + def + "的防御力抵御了进攻！");
            System.out.println("当前生命值为：" + blood);
        } else {
            System.out.println("防御失败！\n英雄" + this.name + "以" + def + "的防御力未能抵御进攻");
            System.out.println("当前生命值为：" + (blood - (attackPower - def)));
        }
    }

    public void learn(Skill newSkill) {

        if (newSkill.getState() > this.mySkill.getState()) {
            System.out.println(mySkill.getSkillName() + "等级过低，不需要学习");
        } else {
            this.mySkill = newSkill;
        }

    }
}
